<?
ob_start();
session_start();
?>
<link rel="stylesheet" type="text/css" href="../style/style.css">
<title>Laporan Cuti Karyawan</title>
<body class="contentlist">
<?
include("../lib/config.php");
$show	= $HTTP_GET_VARS['show'];

// cek hak akses untuk cabang
		$sad = mssql_query("SELECT nama_menu FROM VPrivUser A, VCabang B WHERE username='".$HTTP_SESSION_VARS['user_login']."' AND baca='1' AND A.nama_menu=B.Kode_Cabang",$conn);
		while($rad = mssql_fetch_array($sad)){
		// VARIABLE UNTUK CABANG
		$VAreaCode[] = $rad[0];
		}

?>
<fieldset><legend><b>Laporan Cuti Karyawan</b></legend>
<table width="100%" class="contentlist">
<?
	if(empty($show)){
?>
 <tr>
  <td colspan="2" class="contentlist">&nbsp;Silahkan Pilih report yang akan dibuat:</td>
 </tr>
 <tr class="contentlist"> 
  <td align="center"><b><a href="<?=$PHP_SELF?>?show=tahunan">Cuti Tahunan</a></td>
  <td align="center"><b><a href="<?=$PHP_SELF?>?show=besar">Cuti Besar</a></td>
 </tr>
<?
	}
	if($show == "tahunan"){
?>
 <tr>
  <td colspan="2">Cuti Tahunan<br>
  <hr noshade size="-2">
  </td>
 </tr>
 <tr>
  <td width="20%">Periode:</td>
  <td>Divisi/Biro/Cabang:</td>
 </tr>
 <form action="rep_cuti_tahunan.php" target="_blank" method="get">
 <tr>
  <td>
   <select name="periode">
<?
		$sql = mssql_query("SELECT periode FROM CutiTahunan GROUP BY periode ORDER BY periode DESC",$conn);
		while($row = mssql_fetch_array($sql)){
			echo"
			  <option value='$row[0]'>$row[0]</option>
			";
		}
?>
  </select>
 </td>
 <td>
  <select name="divisi"  style="width:300px;">
   <?
	$sqlQ   = "SELECT * FROM VLevelCabang WHERE status='1' ";
   	$sqlQ	.= "AND AreaCode IN (";

	for($k=0;$k<count($VAreaCode);$k++){
		$sqlQ .= "'$VAreaCode[$k]',";
	}

	$sqlQ 	.= "'$VAreaCode[0]') ";		
	$sqlQ 	.= " ORDER BY uraian ASC";

   	$sql2 = mssql_query($sqlQ,$conn);
		echo"<option value='ALL'>--SEMUA--</option>";
	while($row2 = mssql_fetch_array($sql2)){
		echo"
		 <option value='$row2[kode_so]'>$row2[uraian]</option>
		";
	}
   ?>
  </select>
  <input type="submit" value="Cetak" class="button">
 </td>
</tr> 
<?
	}
	if($show == "besar"){
?>
 <tr>
  <td colspan="2">Cuti Besar<br>
  <hr noshade size="-2">
  </td>
 </tr>
 <tr>
  <td width="20%">Periode:</td>
  <td>Divisi/Biro/Cabang:</td>
 </tr>
 <form action="rep_cuti_besar.php" target="_blank" method="get">
 <tr>
  <td>
   <select name="periode">
<?
		$sql = mssql_query("SELECT periode FROM Cuti WHERE id_JenisCuti='2' GROUP BY periode ORDER BY periode DESC",$conn);
		while($row = mssql_fetch_array($sql)){
			echo"
			  <option value='$row[0]'>Periode $row[0]</option>
			";
		}
?>
  </select>
 </td>
 <td>
  <select name="divisi"  style="width:300px;">
   <?
	$sqlQ   = "SELECT * FROM VLevelCabang WHERE status='1' ";
   	$sqlQ	.= "AND AreaCode IN (";

	for($k=0;$k<count($VAreaCode);$k++){
		$sqlQ .= "'$VAreaCode[$k]',";
	}

	$sqlQ 	.= "'$VAreaCode[0]') ";		
	$sqlQ 	.= " ORDER BY uraian ASC";

   	$sql2 = mssql_query($sqlQ,$conn);
		echo"<option value='ALL'>--SEMUA--</option>";
	while($row2 = mssql_fetch_array($sql2)){
		echo"
		 <option value='$row2[kode_so]'>$row2[uraian]</option>
		";
	}
   ?>
  </select>
  <input type="submit" value="Cetak" class="button">
 </td>
</tr> 
<?
	}
?>
</form>
</table>
<br><br><br>
<center>
<input type="button" value="Tutup" class="button" onClick="Javascript:window.close()">
<input type="button" value="Kembali" class="button" onClick="Javascript:history.back()">
<br /><br />
</center>